import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.Stack;

public class ReversePolish {
    static boolean isNumber(String str) {
        try {
            Integer.parseInt(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public static void main(String[] args) {
        Stack<Integer> s = new Stack<>();
        Scanner read = new Scanner(System.in);
        String str = read.nextLine();
        String[] pokens = str.trim().split("\\s+");
        int ans = 0;
        for (String e : pokens) {
            if (isNumber(e)) {
                int num = Integer.parseInt(e);
                s.push(num);
            } else {
                char c = e.charAt(0);
                int num2 = s.pop();
                int num1 = s.pop();
                if (c == '+')
                    ans = num1 + num2;
                if (c == '-')
                    ans = num1 - num2;
                if (c == '*')
                    ans = num1 * num2;
                if (c == '/')
                    ans = num1 / num2;
                s.push(ans);
            }
        }
        System.out.println(s.pop());
    }
}

